Arduino Programming: Tip and Tricks to Learn Arduino Programming Efficiently by Nicholas Stuart

Arduino Programming: Tip and Tricks to Learn Arduino Programming Efficiently by Nicholas Stuart

Author:Nicholas, Stuart [Nicholas, Stuart]
Language: eng
Format: azw3, epub, pdf
Published: 2020-09-05T16:00:00+00:00


In the structure of an external power supply should be used if possible, as it improves considerably the sensor accuracy (9V AC adapter or 9V battery).

Sketch:

int TMP36 = A0;​ // The sensor A0 is to be connected to the analog pin. We

// call the pin from now "TMP36"

int temperature = 0;​ // Under the variable "temperature" is later

// temperature value stored

int temp [10];​ // This yields good values, you first read multiple values

// and then averages the results. The square bracket "[10]" generated here

// equal to ten variables named "temp [0],” "temp [2],” "temp [3]"... to...

//"temp[9]".Mit the notation [10] So you can save only a little Place .

int time= 20;​ // The value for "time" is in the code, the time intervals

// ago between the individual measurements. void set up() {

Serial.begin(9600);​ // In the setup we start serial communication so

// we can show us the temperature later. About the serial

// communication the board, sending measurements to the computer. In the Arduino

// software can be under "Tools" the "Serial Monitor" start the readings

// to see.

}

void loop() {

temp [0] = map(analog read(TMP36),​ 0​ 410​ -50,​ 150);

delay(time);​

temp [1] = map(analog read(TMP36),​ 0​ 410​ -50,​ 150);

delay(time);​

temp [2] = map(analog read(TMP36),​ 0​ 410​ -50,​ 150);

delay(time);​

temp [3] = map(analog read(TMP36),​ 0​ 410​ -50,​ 150);

delay(time);​

temp [4] = map(analog read(TMP36),​ 0​ 410​ -50,​ 150);

delay(time); ​

temp [5] = map(analog read(TMP36),​ 0​ 410​ -50,​ 150);

delay(time);​

temp [6] = map(analog read(TMP36),​ 0​ 410​ -50,​ 150);

delay(time);​

temp [7] = map(analog read(TMP36),​ 0​ 410​ -50,​ 150);

delay(time);​

temp [8] = map(analog read(TMP36), 0, 410, -50, 150); delay(time);

temp [9] = map(analog read(TMP36), 0, 410, -50, 150);​ // From here is ten times the

read // temperature. In between is ever a break with the duration

// "time" in milliseconds. But what happens here, exactly? Let's look at the

// command once more closely.

// temp [1] = map (analog read (TMP36), 0, 410, -50, 150);

//Sequentially:

// temp [1] - is the name of the first variable.

// "map (a, b, c, d, e)" - This is the so-called "Map command". Allows

// to a read-in value (a) in which the values between (b) and (c) lie,

// convert it into a different speed range, and that (d) in the area between

// and (e).

// following our command happens:

// the value of the sensor is read out directly in the "Map" command wit h

// "analog read (TMP36)". The measured values should be between 0 and 410th The

// corresponds to the analog port of the values between 0V and 2V. is the voltage

// the sensor out at temperatures between -50 ° C and + 150 ° C. These values on

// analog port will now be through the "Map command" directly to the Celsius values

// -50 to 150 converted.

temperature = (temp [0] + temp [1] + temp [2] + temp [3] + temp [4] + temp [5] + temp [6] + temp [7] + temp temp [8] + [ 9]) / 10; // All in a row. Here every ten are found

// temperature values added together and divided by ten. The

// average value is stored under the variable "temperature"

Serial.print(temperature);​ // Now, the value of "temperature" over the serial

// sent communications to the PC.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Architecting High-Performance Embedded Systems by Jim Ledin(1324)
DIY Microcontroller Projects for Hobbyists by Miguel Angel Garcia-Ruiz Pedro Cesar Santana Mancilla(1247)
Raspberry Pi For Dummies by Sean McManus(761)
Computers for Seniors for Dummies by Nancy C. Muir(621)
Troubleshooting and Maintaining PCs All-in-One For Dummies by Dan Gookin(566)
Windows 10: The Missing Manual by Pogue David(522)
Arduino Uno: A Hands-On Guide for Beginner by Agus Kurniawan(466)
Getting Started with Adafruit FLORA by Becky Stern(462)
Teach Yourself VISUALLY Chromebook by Guy Hart-Davis(434)
Samsung Galaxy S6 for Dummies by Bill Hughes(418)
IMac for Dummies by Chambers Mark L.;(373)
Raspberry Pi: A Step-by-Step Guide For Beginners to Program and Set-Up Top 10 Raspberry Pi Projects + First Steps on Configuration by Cage Jonathan(367)
Raspberry Pi 4: The Ultimate Step-by-Step Guide to Using Raspbian to Create Incredible Projects and Expand Your Programming Skills with the Latest Version of Raspberry Pi by Liam Clark(356)
iPad For Seniors For Dummies by Jesse Feiler(350)
2020 Ultimate Guide to Raspberry Pi : Tips, Tricks and Hacks by oney Youssef & oney Youssef(349)
Software Architecture by Neal Ford(345)
Super Arduino: Step-by-Step Instructions to Build Cool Gadgets by Kenneth Hawthorn(334)
Raspberry Pi: Tips and Tricks to Learn Raspberry Pi Programming by Pratt Logan(322)
Build Your Own Autonomous NERF Blaster by Bryce Bigger(312)
RASPBERRY PI 4 : A Comprehensive Guide to Raspberry Pi 4 Setup, Learning Programming and Developing Innovative Projects by DENTON DUKE(312)